import { request } from '@umijs/max';

export async function queryArticleList(
  params: {
    keyword?: string;
    current?: number;
    pageSize?: number;
  },
  options?: { [key: string]: any },
) {
  return request<API.Result_PageInfo_UserInfo__>('/api/v1/queryArticleList', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

export async function queryCategoryList() {
  return request<API.Result_PageInfo_UserInfo__>('/api/v1/queryCategoryList');
}

export async function addArticle(options?: { [key: string]: any }) {
  return request<API.RuleListItem>('/api/v1/article', {
    method: 'POST',
    data:{
      method: 'post',
      ...(options || {}),
    }
  });
}

export async function editArticle(id:string,options?: { [key: string]: any }) {
  return request<API.RuleListItem>(`/api/v1/article/${id}`, {
    method: 'PUT',
    data:{
      method: 'put',
      ...(options || {}),
    }
  });
}